﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mitasoft.AdsShedule.Business;
using mitasoft.AdsShedule.Common;

namespace mitasoft.AdsShedule.Forms
{
    public partial class DisplayInfo : Form
    {
        public List<VoiceBO> VoiceBOList { get; set; }

        public Common.AppoimentButtonInfo ButtonInfo { get; set; }
        public Common.IntervalType InvervalType { get; set; }

        public DisplayInfo()
        {
            InitializeComponent();
            this.CancelButton = btnClose;
            this.Load += new EventHandler(DisplayInfo_Load);
        }

        void DisplayInfo_Load(object sender, EventArgs e)
        {

            dataGridHistory.AutoGenerateColumns = false;
            dataGridHistory.DataSource = BusinessAccess.Instance.GetClientOccur(IntervalType.ALL);

            //Business.AdDS.VoiceClientAssocRow voiceRow = null;
            //    //Business.BusinessAccess.Instance.GetVoiceClientAssociations(ButtonInfo.VoiceAssocID);

            ////selected date
            //lblSelectedDate.Text = string.Format("{0}@{1}", ButtonInfo.Data.ToString("dd-MMM-yyyy"), ButtonInfo.InvervalType.ToString());

            ////selected client
            //lblSelectedClient.Text = voiceRow != null ? string.Format("{0}", voiceRow.Description) : "No client/voice associated.";

            ////aparitii
            //string mesajClient = "Clientul apare de {0} ori luna aceasta";
            //int aparitii = -1;
            //VoiceBOList = Business.BusinessAccess.Instance.GetNumarAparitiiClient(voiceRow.ClientRow.ID, out aparitii);
            //lblNumarAparitiiClient.Text = voiceRow != null ? string.Format(mesajClient, aparitii) : string.Format(mesajClient, 0);

            ////history
            //dataGridHistory.DataSource =
            //    (from v in VoiceBOList
            //     orderby v.Data, v.IntervalText ascending
            //     select v).ToList();
        }

        private void FilterData(IntervalType interval)
        {
            if (interval == IntervalType.ALL)
            {
                dataGridHistory.DataSource = (from v in VoiceBOList
                                              orderby v.Data, v.IntervalText ascending
                                              select v).ToList();
            }
            else
            {
                dataGridHistory.DataSource = (from v in VoiceBOList
                                              where v.IntervalText.Equals(interval.ToString())
                                              orderby v.Data, v.IntervalText ascending
                                              select v).ToList();
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void DisplayInfo_Load_1(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void btnAll_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.ALL);
        }

        private void btnAM1_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.AM1);
        }

        private void btnAM2_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.AM2);
        }

        private void btnAM3_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.AM3);
        }

        private void btnPM1_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.PM1);
        }

        private void btnPM2_Click(object sender, EventArgs e)
        {
            FilterData(IntervalType.PM2);
        }
    }
}
